//package com.bestcem.xm.award.service.impl;
//
//import com.bestcem.xm.award.service.GrpcPlatformService;
//import com.bestcem.xm.award.service.dto.draw.PageDTO;
//import com.bestcem.xm.award.service.dto.grpcplatform.CreateGrpcPlatformParam;
//import com.bestcem.xm.award.service.dto.grpcplatform.GrpcPlatformDTO;
//import com.bestcem.xm.common.core.grpcplatform.entity.ListGrpcPlatformsParam;
//import com.bestcem.xm.common.core.grpcplatform.entity.UpdateGrpcPlatformParam;
//import com.bestcem.xm.common.core.grpcplatform.dao.GrpcPlatformDao;
//import com.bestcem.xm.common.core.grpcplatform.entity.GrpcPlatformDO;
//import com.bestcem.xm.common.core.domain.web.ServiceResult;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.util.CollectionUtils;
//
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * @author sh.pei <sh.pei@idiaoyan.com>
// * @version v1.0
// * @date 2021/7/21 17:55
// */
//@Service
//public class GrpcPlatformServiceImpl implements GrpcPlatformService {
//
//    @Autowired
//    private GrpcPlatformDao grpcPlatformDao;
//
//    @Override
//    public ServiceResult<PageDTO<GrpcPlatformDTO>> listGrpcPlatforms(ListGrpcPlatformsParam param) {
//        Long count = grpcPlatformDao.count(param);
//        PageDTO pageDTO = new PageDTO();
//        pageDTO.setTotal(count);
//        if (count == 0) {
//            return ServiceResult.success(pageDTO);
//        }
//        List<GrpcPlatformDO> grpcPlatformDOS = grpcPlatformDao.listGrpcPlatforms(param);
//        if (!CollectionUtils.isEmpty(grpcPlatformDOS)) {
//            List<GrpcPlatformDTO> list = grpcPlatformDOS.stream().filter(Objects::nonNull).map(this::convert).collect(Collectors.toList());
//            pageDTO.setData(list);
//        }
//        return ServiceResult.success(pageDTO);
//    }
//
//    private GrpcPlatformDTO convert(GrpcPlatformDO grpcPlatformDO) {
//        GrpcPlatformDTO grpcPlatformDTO = new GrpcPlatformDTO();
//        grpcPlatformDTO.setId(grpcPlatformDO.getId());
//        grpcPlatformDTO.setCode(grpcPlatformDO.getCode());
//        grpcPlatformDTO.setPCode(grpcPlatformDO.getPCode());
//        grpcPlatformDTO.setName(grpcPlatformDO.getName());
//        grpcPlatformDTO.setEnabled(grpcPlatformDO.isEnabled());
//        grpcPlatformDTO.setAllowIps(grpcPlatformDO.getAllowIps());
//        grpcPlatformDTO.setSecretKeys(grpcPlatformDO.getSecretKeys());
//        return grpcPlatformDTO;
//    }
//
//    @Override
//    public ServiceResult<GrpcPlatformDTO> getGrpcPlatform(String id) {
//        GrpcPlatformDO grpcPlatformDO = grpcPlatformDao.findById(id);
//        if (grpcPlatformDO == null) {
//            return ServiceResult.fail("没有数据");
//        }
//
//        return ServiceResult.success(convert(grpcPlatformDO));
//    }
//
//    @Override
//    public ServiceResult<String> createGrpcPlatform(CreateGrpcPlatformParam param) {
//        GrpcPlatformDO grpcPlatformDO = new GrpcPlatformDO();
//        grpcPlatformDO.setCode(param.getCode());
//        grpcPlatformDO.setPCode(param.getPCode());
//        grpcPlatformDO.setName(param.getName());
//        grpcPlatformDO.setEnabled(param.isEnabled());
//        grpcPlatformDO.setAllowIps(param.getAllowIps());
//        grpcPlatformDO.setSecretKeys(param.getSecretKeys());
//        grpcPlatformDO = grpcPlatformDao.save(grpcPlatformDO);
//        return ServiceResult.success(grpcPlatformDO.getId());
//    }
//
//    @Override
//    public ServiceResult<String> updateGrpcPlatform(String id, UpdateGrpcPlatformParam param) {
//        grpcPlatformDao.updateById(id, param);
//        return ServiceResult.success(id);
//    }
//
//    @Override
//    public ServiceResult deleteGrpcPlatform(String id) {
//        grpcPlatformDao.deleteById(id);
//        return ServiceResult.success();
//    }
//}
